
console.info('vue-html-base.js')

//进度条
/*

            <el-dialog :title="progress.title" :visible.sync="progress.visible" :close-on-click-modal="false" :show-close="false" top="3vh" width="200px">     
                <el-progress :percentage="progress.percentage"></el-progress>
            </el-dialog>
    //配置
    progress:autoAddProgress()
    //开始
    progress.open()
    //结束
    progress.close()
*/

function autoAddProgress(conf) {
    var obj = pageData({
        expectSecond:100,//预期要执行几秒
        thisPath:"app.progress",//必输项
        title:"处理进度",
        visible:false,
        percentage:0,
        addTimes:0,//add方法调用的次数
        setIntervalId:null,
        //打开
        open(){
            this.visible=true;  
            this.percentage=0
            this.addTimes=0;
            this.setIntervalId=setInterval(this.thisPath+".add()","1000");

        },
        //自动加百分比
        add(){
            this.percentage=parseInt(100*(++this.addTimes* 100)/this.expectSecond)/100;
            if(this.percentage>=100){
                this.addTimes=0
            }
        },
        //关闭
        close(){
            this.visible=false; 
            clearInterval(this.setIntervalId);
        }
    })
    return Object.assign(obj, conf!=null?conf:{})
}




//日志
/*

    <el-dialog title="日志" :visible.sync="log.visible" :close-on-click-modal="false" :modal="false" top="3vh"
        width="800px">

        <el-table :data="log.tableData" size="mini" :stripe="true" :fit="true" border
            style="width: 100%; padding-left:20px; padding-bottom: 20px;">
            <el-table-column prop="creatorName" label="操作人" width="60">
            </el-table-column>
            <el-table-column prop="createDate" label="操作时间" width="160">
            </el-table-column>
            <el-table-column prop="action" label="操作" width="60">
            </el-table-column>
            <el-table-column prop="opinion" label="备注">
            </el-table-column>

        </el-table>

        <el-pagination v-if="log.needPage" :small="true" :current-page="log.pageCurrent" :page-sizes="log.pageSizes"
            :page-size="log.pageSize" :total="log.dataCount" @size-change="log.pageSizeChange"
            @current-change="log.pageCurrentChange" @prev-click="log.prevChange" @next-click="log.nextChange"
            layout="total, sizes, prev, pager, next, jumper">
        </el-pagination>
        <span slot="footer" class="dialog-footer">
            <el-button size="small" type="info" @click="log.visible=false">取消</el-button>
        </span>
    </el-dialog>




初始化
log: logDialog("价格复制"),
或者
log: logDialog({
    searchData: {
        dept:null,
        action: "一键更新",
        logo: "物价维护",
    },
    dealReceiveList(list){
        for(var row of list){
            if(row.opinion!=null){
                var data=eval("("+row.opinion+")")
                row.TMP=data.TMP
                row.CID=data.CID
            }

        }
        return list;
    },
    needPage: true,
}),

调用
log.open(id)


*/
function logDialog(logo) {
    var obj = pageData({
        visible: false,
        url: "baseLog/list.do",
        needPage: false,
        searchData: {
            id: null,//业务id
            logo: null,//业务标识
        },
        open(id) {
            this.visible = true;
            this.searchData.id = id
            this.list();
        }
    })


    //对象赋值
    if (logo != null && logo.constructor === Object) {
        return Object.assign(obj, logo)
    } else {
        obj.searchData.logo=logo
    }


    return obj;
}






//上传文件
/*
<el-dialog title="选择文件" :visible.sync="upload.visible" :close-on-click-modal=false
      top="3vh">

    <el-form :inline="true" class="demo-form-inline" size="mini">
        <el-form-item label="公司名称：">
            <select2 v-model="upload.paras.dept" url="select2/dsoms/dept.do?ctrl=true" style="width:100px">
            </select2>
        </el-form-item>

    <star></star> <el-form-item label="客户名称：">
            <select2 v-model="upload.paras.rasClientId"
                :url="'select2/dsoms/rasClientId.do?ctrl=true&dept='+upload.paras.dept" style="width:150px">
            </select2>
        </el-form-item>

        <el-form-item label="">
        <input id="file1" type="file" @change="upload.getFile($event)">
    </el-form-item>


        </el-form>

    <div style="text-align: left">
        
        
    </div>
    <span slot="footer" class="dialog-footer">
        <el-button @click="upload.submitUpload($event)" type="primary" size="mini"> 上传</el-button>
        <el-button @click="upload.cancelImpDialog()" size="mini">取消</el-button>
    </span>
</el-dialog>





data: {
    upload:uploadData('coor/customerImport/import.do','file1'),
     upload:uploadData({
        url:'coor/customerImport/import.do',
        fileId:'file1',
     }),
},
mounted() {
    this.$nextTick(function () {
        this.upload.beforeUpload=function(){
            if(this.paras.rasClientId==null){
                alert('客户名称不能为空')
                return false
            }
            return true;
        }
    })

},
*/
function uploadData(url, fileId, afterUpload) {

    var conf={}

    if(url!=null){
        if(url.constructor === Object){
            conf=url
        }else{
            conf={
                url:url,
                fileId:fileId,
                afterUpload:afterUpload,
            }

        }

    }


    var obj = {
        url: null,
        fileId:'file1',
        paras: {},//提交参数
        files: [],//上传文件
        visible: false,//对话框是否显示
        uploadLock: false,
        colseAfterUpload:true,
        afterOpen: null,
        afterUpload: null,
        beforeUpload: null,
        open() {
            this.visible = true;
            this.paras = {};
            this.uploadLock = false;
            if(this.afterOpen!=null){
                this.afterOpen();
            }
        },
        submitUpload() {
            console.info('uploadData')
            if (this.beforeUpload != null) {
                if (!this.beforeUpload()) {
                    return;
                }
            }


            if (this.files.length == 0) {
                alert("未选择文件!");
                return;
            }

            event.preventDefault();
            let formData = new FormData();
            formData.append('file', this.files[0]);
            for (var k in this.paras) {
                formData.append(k, this.paras[k]);
            }
            formData.append("ts", new Date().getTime());
            let config = {
                headers: {
                    'Content-Type': 'multipart/form-data'
                }
            }

            if (this.uploadLock)
                return;

            this.uploadLock = true;
            var that = this;


            // 开启加载动画
            this.loading = Vue.prototype.$loading({ lock: true, text: 'Loading', spinner: 'el-icon-loading', background: '#ffffffb3', });






            Vue.http.post(this.url, formData, config).then(function (res) {
                //关闭加载动画
                that.loading.close();
                //alert(res.data.message);
                if (res.data.code == 1) {
                    alert("导入成功")
                    if(that.colseAfterUpload){
                        that.cancelImpDialog();
                    }
                   
                    if (that.afterUpload != null) {
                        that.afterUpload(res.data.data);
                    }

                } else {
                    alert(res.data.message);
                }
                // 解锁
                that.uploadLock = false;
            })
        },
        cancelImpDialog() {
            this.visible = false;
            this.files = [];
            this.uploadLock = false;
            $("#" + this.fileId).val("");
        },
        getFile(event) {
            this.files = event.target.files;
        },


    }
    return Object.assign(obj, conf);;
}


//分页表格
/*

<div id="content" style=" position: fixed;top: 60px;bottom: 57px;overflow-y: scroll;overflow: auto;width:100%">
    <el-table :data="clientpriceList.tableData"  :ref="clientpriceList.ref" size="mini" :stripe="true" :fit="true" border
 @current-change="clientpriceList.currentChange"
 @selection-change="clientpriceList.selectionChange"
        style="width: 100%; padding-left:10px; padding-bottom: 20px;">

        <el-table-column v-if="clientList.hasChecked" width="30">
            <template slot="header" slot-scope="scope">
                <el-checkbox v-model="clientList.checked" @change="clientList.checkAll"></el-checkbox>
            </template>
            <template slot-scope="scope">
                <el-checkbox v-model="scope.row.checked"></el-checkbox>
            </template>
        </el-table-column>



        <el-table-column label="序号" width="50">
            <template slot-scope="scope">
                {{scope.$index+1}}
                <span style="display: none;">{{scope.row.id}}</span>
            </template>
        </el-table-column>
        <el-table-column prop="billCode" label="导入单号">
        </el-table-column>
    </el-table>
</div>
<div id="footer"
    style="border-top: 1px solid #cfd7e5; width:100%; bottom: 0px; position: fixed; padding: 15px;">
    <el-pagination :small="true" :current-page="clientpriceList.pageCurrent" :page-sizes="[10, 20, 30, 50]"
        :page-size="clientpriceList.pageSize" :total="clientpriceList.dataCount" @size-change="clientpriceList.pageSizeChange"
        @current-change="clientpriceList.pageCurrentChange" @prev-click="clientpriceList.prevChange" @next-click="clientpriceList.nextChange"
        layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>
</div>



data: {
    clientpriceList: pageData({
                        url: "clientPrice/list.do",
                        searchData: {
                            rasClientId: null,
                            spCode: null,
                            spName: null,
                            testCode: null,
                            testNo: null,
                        },
                        setHeight() {
                            this.height = window.innerHeight - 275
                        },
                        rowId:"id",
                        rowFullUrl:"dsoms/sampleToAdjust/listRowSupplement.do?id="
                    }),
},
mounted() {
    this.$nextTick(function () {
        this.clientpriceList.list();
        this.clientpriceList.setHeight();
    })

},


*/


function pageData(url, searchString, needPage) {



    var obj = {
        visible:true,
        ref: null,

        //多选框，选中数据,还有一种取值方式是：app.$refs.clientpriceList.selection
        multipleSelection: [],
        selectionChange(val) {
            obj.multipleSelection = val;
        },

        searchData: {},//查询条件
        needPage: needPage != null ? needPage : true,
        url: url,


        tableData: [],//具体数据

        //_/_/_/_/_/_/_/_/_/ 全选全消 开始_/_/_/_/_/_/_/_/
        //是否有复选框
        hasChecked: false,
        checked: false,//title 部分的全选全消
        checkAll() {
            var that = obj;
            for (var row of that.tableData) {
                row.checked = that.checked;
            }

        },
        //如果field为空，返回行的集合，如果field不为空，则返回字段值的集合
        getCheckedRows(field) {
            var list = [];
            for (var row of obj.tableData) {
                if (row.checked == true) {
                    if (field != null) {
                        list.push(row[field])
                    } else {
                        list.push(row)
                    }
                }
            }
            return list;

        },

        //_/_/_/_/_/_/_/_/_/ 全选全消 开始_/_/_/_/_/_/_/_/


        //_/_/_/_/_/_/_/_/_/ 对查出的数据进行过滤 开始_/_/_/_/_/_/_/_/

        /*
                <el-table-column width="30" >
                    <template slot="header" slot-scope="scope">
                        <el-checkbox v-model="templateClientList.allChecked" @change="allChecked()"></el-checkbox>
                    </template>
                    <template slot-scope="scope">
                        <el-checkbox v-model="scope.row.checked"  @change="oneChecked(scope.row)"></el-checkbox>
                    </template>
                </el-table-column>
                
                 allChecked(){
                    for(var row of this.templateClientList.tableDataWithFilter){
                        row. checked=this. templateClientList.allChecked
                    }
                    this.templateClientList.initTableDataChecked()
                },
                oneChecked(row){
                    this.templateClientList.initTableDataChecked()
                },
        */
        filterData: null,//过滤条件
        tableDataWithFilter: [],//过滤的数据
        tableDataWithFilterFun() {
            console.info('tableDataWithFilterFun')
            this.tableDataWithFilter.push(this.tableData[0])
            //return 
            var filterData = this.filterData;
            this.tableDataWithFilter = this.tableData.filter((data) => {
                var bool = true;
                for (var key in filterData) {
                    if (isNotEmpty(filterData[key])) {
                        if ((data[key] + "").indexOf(filterData[key] + "") == -1) {
                            bool = false;
                            break;
                        }
                    }
                }
                return bool;
            })
        },
        //把checked转移到tableData
        initTableDataChecked() {
            for (var row of this.tableData) {
                for (var rowF of this.tableDataWithFilter) {
                    if (rowF.rasClientId == row.rasClientId) {
                        row.checked = rowF.checked;
                        break;
                    }
                }
            }
        },
        //_/_/_/_/_/_/_/_/_/ 对查出的数据进行过滤 结束_/_/_/_/_/_/_/_/



        //_/_/_/_/_/_/_/_/_/ 合计行 开始_/_/_/_/_/_/_/_/

        summary:true,//需要合计
        sumChecked:false,//只合计勾选的
        sumProperty:new Set(),//需要合计的字段
        //具体合计方法
        summaryMethod({ columns, data }){
            const sums = [];           
            for(var column of columns){
                if(this.sumProperty.has(column.property)){
                    var sum=0;
                    for(var r of data){
                        const value =(this.sumChecked&&r.checked)? Number(r[column.property]):0;
                        sum += !isNaN(value)?value:0;
                    }
                    sums.push(sum)
                }else{
                    sums.push('')
                }
            }
            sums[0]="合计"
            return sums;
        },




        //_/_/_/_/_/_/_/_/_/ 合计行 结束_/_/_/_/_/_/_/_/



        emptyTableData() {//清空数据
            this.tableData = []
            this.multipleSelection = []
            this.pageCurrent = 1
            this.selectedRow = []
            this.curRow = null
        },
        pageCurrent: 1,
        pageSize: 10,
        pageSizes: [10, 20, 50, 200, 500, 1000],
        dataCount: 0,
        selectedRow: [],//选中行对象
        searchString: searchString,
        beforeSearch: null,//查询前事件
        afterSearch: null,//查询后事件
        useLoading: true,//使用等待框
        loading: null,

        //_/_/_/_/_/_/_/_/_/ 高度设置 开始_/_/_/_/_/_/_/_/
        height: (window.innerHeight - 150),
        setHeight() {
            this.height = window.innerHeight - 150
        },
        //_/_/_/_/_/_/_/_/_/ 高度设置 结束_/_/_/_/_/_/_/_/

        //_/_/_/_/_/_/_/_/_/ 补充行数据的属性 开始_/_/_/_/_/_/_/_/
        rowId: "id",//行里面的id,常见的还有origrec,?_id等
        rowFullUrl: null,//补充数据的url
        //补充数据，使得数据完整
        makeRowFull(row) {
            var url = this.rowFullUrl + "";
            //拼接一个ts，处理已有?问题和缓存问题
            if (url.indexOf("?") != -1) {
                url += "&ts=" + new Date().getTime();
            } else {
                url += "?ts=" + new Date().getTime();
            }
            //拼接参数
            var postData = Object.assign({}, this.searchData)
            for (var name of this.rowId.split(",")) {
                postData[name] = row[name];
            }
            Vue.http.post(url, postData, { emulateJSON: true }).then(function (response) {
                for (var n in response.data.data) {
                    Vue.set(row, n, response.data.data[n])
                }

            })
        },

        //_/_/_/_/_/_/_/_/_/ 补充行数据的属性 结束_/_/_/_/_/_/_/_/

        //注册子表：主表查询后，子表会清空
        tableBIndex: 0,//子表索引
        tableB: [],//子表pageData对象，目前仅用于清空
        tableBFun: [],//行选后子表的方法:一般是做2个事，1把row里面的信息放入查询条件，2执行查询
        //注册子表(子表对象，子表查询方法)
        registerTableB(tbl, tableBFun) {
            this.tableB[this.tableBIndex] = tbl;
            this.tableBFun[this.tableBIndex] = tableBFun;
            this.tableBIndex++;
        },

        //注册点击关联，行记录点击后，会调用里面注册的事件
        handleClickFun: [],
        registerHandleClickFun(fun) {
            this.handleClickFun.push(fun);
        },

        currentChange(row) {//@current-change 事件
            //赋值
            obj.curRow = row;
            //子表事件
            for (var fun of obj.tableBFun) {
                fun(row);
            }
            //注册点击事件
            for (var fun of obj.handleClickFun) {
                fun(row);
            }
            //尾巴
            obj.handleCurrentChange(row);
        },
        handleCurrentChange: function (row) {

        },
        curRow: null,//当前选中的row
        dealReceiveList(list) {//返回数据的处理
            return list;
        },
        //master-slave-query,主从查询，数据放到searchData和tableData，不分页，查询条件是searchData
        //对查询返回结果做处理
        dealReceiveMs(data) {
            return data
        },
        msQuery() {
            this.curRow = null;
            console.info("list()")
            var that = this;
            if (that.useLoading) {
                // 开启加载动画
                that.loading = Vue.prototype.$loading({ lock: true, text: 'Loading', spinner: 'el-icon-loading', background: '#ffffffb3', 'z-index': 4000 });
            }


            var searchData = {}
            if (this.searchString == null) {
                searchData = that.searchData;
            } else {
                searchData = eval(this.searchString)
            }

            var url = this.url

            if (this.needPage) {

                if (this.url.indexOf("?") != -1) {
                    url += "&pageSize=" + this.pageSize + "&pageCurrent=" + this.pageCurrent
                } else {
                    url += "?pageSize=" + this.pageSize + "&pageCurrent=" + this.pageCurrent
                }
            }

            Vue.http.post(url, searchData, { emulateJSON: true }).then(function (response) {

                if (response.data.code == 1) {
                    var r = that.dealReceiveMs(response.data.data);
                    that.searchData = r.main;
                    that.tableData = that.dealReceiveList(r.list);
                }
                if (that.afterSearch != null) {
                    that.afterSearch();
                }
                if (that.useLoading) {
                    that.loading.close();
                }
            })
        },
        listCheck() {
            return true;
        },
        //导出  list出来数据的导出，导出条件是searchData
        exportUrl: null,
        exportMethod: 'GET',
        export(exportData) {
            console.info("export")
            if (this.exportUrl == null) {
                this.exportUrl = this.url + "Export";//
            }
            if ('post' == this.exportMethod.toLowerCase()) {
                var inputs = '';
                for (var k in this.searchData) {
                    if (this.searchData[k] instanceof Object) {

                    } else {
                        inputs += '<input type="hidden" name="' + k + '" value="' + this.searchData[k] + '" />';
                    }
                }
                if(exportData!=null){
                    for (var k in exportData) {           
                            inputs += '<input type="hidden" name="' + k + '" value="' + exportData[k] + '" />';
                    }
                }
                jQuery('<form action="' + this.exportUrl + '" method="post">' + inputs + '</form>').appendTo('body').submit().remove();
            } else {
                var inputs = '';
                for (var k in this.searchData) {
                    if (this.searchData[k] instanceof Object) {

                    } else {
                        inputs += '&' + k + '=' + this.searchData[k];
                    }
                }
                if(exportData!=null){
                    for (var k in exportData) {           
                        inputs += '&' + k + '=' + exportData[k];
                    }
                }
                window.open(this.exportUrl + (this.exportUrl.indexOf('?') > 0 ? '' : '?1=1') + inputs)
            }

        },
        //排序的翻译，比如字段传入testcode，sql的xml里面2张表join都有testcode，那这里就要写"testcode":"a.testcode"
        orderTrans:{


        },
        orderBy:null,
        //排序
        sortChange(val  ){
            console.info(val)
            //根据那个字段排序
            var prop=val.prop;
            if(obj.orderTrans[prop]!=null){
                prop=obj.orderTrans[prop];
            }

            //排序方式
            var order=val.order=='descending'?'desc':'asc';

            obj.orderBy=prop +" "+ order

            obj.list();
        },

        //列表查询
        list() {

            if (this.beforeSearch != null) {
                this.beforeSearch();
            }

            this.curRow = null;
            console.info("list()")
            var that = this;

            if (!this.listCheck()) {
                console.info("查询校验失败")
                return;
            }

            if (that.useLoading) {
                // 开启加载动画
                that.loading = Vue.prototype.$loading({ lock: true, text: 'Loading', spinner: 'el-icon-loading', background: '#ffffffb3' });
            }


            var searchData = {}
            if (this.searchString == null) {
                searchData = Object.assign(that.searchData);
            } else {
                searchData = eval(this.searchString)
            }



            var url = this.url
            if (this.needPage) {

                if (this.url.indexOf("?") != -1) {
                    url += "&pageSize=" + this.pageSize + "&pageCurrent=" + this.pageCurrent
                } else {
                    url += "?pageSize=" + this.pageSize + "&pageCurrent=" + this.pageCurrent
                }
            }

            if(this.orderBy!=null){
                searchData.orderBy=this.orderBy
            }

        console.info("list()->"+url)

            Vue.http.post(url, searchData, { emulateJSON: true }).then(function (response) {
                if (that.useLoading) {
                    that.loading.close();
                }


                if (response.data.code == 0) {
                    alert(response.data.message)
                } else if (response.data.code == 1) {
                    if (response.data.data.list == null) {
                        console.error("列表查询返回null，可能返回结构不对")
                    }
                    if (that.hasChecked) {
                        for (var row of response.data.data.list) {
                            if (row.checked == null) {
                                row.checked = false;
                            }
                        }
                    }
                    that.tableData = that.dealReceiveList(response.data.data.list);
                    that.dataCount = response.data.data.total;
                } else {
                    if (that.hasChecked) {
                        for (var row of response.data.data.list) {
                            if (row.checked == null) {
                                row.checked = false;
                            }
                        }
                    }
                    that.tableData = that.dealReceiveList(response.data.rows);
                    that.dataCount = response.data.total;
                }

                if (that.rowFullUrl != null && that.rowId != null) {
                    for (var row of that.tableData) {
                        that.makeRowFull(row)
                    }
                }
                //正常查询完成后清除子表数据
                for (var table of that.tableB) {
                    table.tableData = []
                    table.tableDataWithFilter = []
                }

                if (that.afterSearch != null) {

                    that.afterSearch();
                }
                //如果过滤条件不为空，则需要过滤)

                if (that.filterData != null)
                    that.tableDataWithFilterFun();

            })
        },

        //选中列变化
        handleSelectionChange(val) {
            obj.selectedRow = val;
        },


        // Tools-分页数改变
        pageSizeChange: function (size) {
            obj.pageSize = size;
            obj.list();
        },

        // Tools-当前页
        pageCurrentChange: function (current) {
            obj.pageCurrent = current;
            obj.list();
        },

        // Tools-上一页
        prevChange: function (current) {
            obj.pageCurrent = current;
            obj.list();
        },

        // Tools-下一页
        nextChange: function (current) {
            obj.pageCurrent = current;
            obj.list();
        },
    }

    //对象赋值
    if (url != null && url.constructor === Object) {
        return Object.assign(obj, url)
    } else {
        obj.url = url;        
        if(searchString!=null){
            obj.searchString = searchString;
        }
        if(needPage!=null){
            obj.needPage = needPage;
        }
    
    }


    return obj;

}

/*
<!--选公司-->
<el-dialog title="分配公司" :visible.sync="deptDistribute.visible" width="600px">
    <el-form :inline="true" class="demo-form-inline" size="mini" @submit.native.prevent>

        <el-form-item label="">
            <div class="columnQuery">
                <table v-if="false">
                    <tbody>

                        <tr>
                            <td class="td_left_main"><label class="label_td">套餐编码</label></td>
                            <td class="td_right_main">
                                <el-input v-model="deptDistribute.searchData.code" style="">
                                </el-input>
                            </td>
                        </tr>
                        <tr>
                            <td class="td_left_main"><label class="label_td">套餐名称</label></td>
                            <td class="td_right_main">
                                <el-input v-model="deptDistribute.searchData.name" style="">
                                </el-input>
                            </td>
                        </tr>


                        <tr>
                            <td class="td_left_main">
                                <el-button type="primary" @click="deptDistribute.queryPrepare()">查询
                                </el-button>

                            </td>
                        </tr>
                    </tbody>
                </table>
            </div>
        </el-form-item>
        <el-form-item>

            <el-transfer filterable filter-placeholder="按名称过滤查询结果" v-model="deptDistribute.selectedData"
                :data="deptDistribute.prepareData" :titles="['待选公司', '已选公司']" style="margin-left:5px;">
                <span slot-scope="{ option }" :title="option.label">{{ option.label }}</span>
            </el-transfer>

        </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
        <el-button @click="deptDistribute.cancel()">取 消</el-button>
        <el-button type="primary" @click="deptDistribute.ok()">确 定</el-button>
    </span>
</el-dialog>




data: {
                    userList: pageData("user/getList.do"),//列表数据

                    tableHeight: window.innerHeight - 130,
                    msg: '',
                    dept: [],

                    currow:null,

                    //公司选择的穿梭框,
                    //第一个url返回ActionResponse 包裹的 {"sel":["a"],"pre":[{"key":"a","label":"A"},{"key":"b","label":"B"}]}
                    //第二个url推送 Object.assign({ list: ["a"] }, )给后台
                    deptDistribute: distributeData("dsmos/userDeptDistribute.do","dsmos/saveUserDept.do"),


                },

                created: function () {
                    console.info("created")


                    //角色列表
                    this.$nextTick(function () {

                        this.userList.list();

                        this.deptDistribute.afterOk=function(){
                            app.handleCurrentChange(app.currow)
                        }

                    })
                },



                methods: {


                    //选中角色改变事件
                    handleCurrentChange(row) {
                        this.currow=row;
                        //复制
                        this.$http.post("dsmos/getUserDept.do?userCode=" + row.name).then(function (response) {
                            if (response.data.code == 1) {
                                //父节点处理
                                this.dept = response.data.data

                            }


                        })

                    },
                    //分配公司
                    editRow(row) {

                        this.deptDistribute.visible = true
                        this.deptDistribute.searchData.userCode = row.name
                        this.deptDistribute.queryPrepare()
                    	

                    },

                }
*/

//穿梭框
function distributeData(searchUrl, okUrl) {

    var obj = {

        searchUrl: searchUrl,
        okUrl: okUrl,

        visible: false,//是否显示
        searchData: {},//查询条件
        prepareData: [],//备选区
        selectedData: [],//已选择
        afterQueryPrepare(){
            
        },
        queryPrepare() {//查询备选区数据

            var that = this;

            Vue.http.post(that.searchUrl, that.searchData, { emulateJSON: true }).then(function (response) {
                if (response.data.code == 1) {
                    that.prepareData = response.data.data.pre;
                    that.selectedData = response.data.data.sel;
                    that.afterQueryPrepare()
                }
            })

        },
        cancel() {//取消
            this.visible = false;
        },
        ok() {//选择

            var that = this;

            if (that.okUrl != null) {

                Vue.http.post(that.okUrl, Object.assign({ list: this.selectedData }, that.searchData), { emulateJSON: true }).then(function (response) {

                    if (response.data.code == 1) {
                        alert('保存成功')
                        that.visible = false;
                        that.prepareData = [];
                        that.selectedData = [];

                    } else {
                        alert(response.data.message)
                    }
                    that.afterOk();

                })

            } else {
                that.visible = false;
                that.prepareData = [];
                that.selectedData = [];
                that.afterOk();
            }

        },
        afterOk() {//保存成功后事件

        }

    };

    return obj;

}





//选测试项目


/*
    
<el-dialog :title="testSel.title" :visible.sync="testSel.visible" :close-on-click-modal=false
custom-class="dialog_pdt_import" top="3vh">

<el-form :inline="true" class="demo-form-inline" size="mini">
    <el-form-item label="测试编码">
        <select2 v-model="testSel.detail.testCode" url="select2/testCode.do" style="width:200px">
        </select2>
    </el-form-item>
    <el-form-item label="测试名称">
        <select2 v-model="testSel.detail.testCode" url="select2/testNo.do" style="width:300px">
        </select2>
    </el-form-item>
</el-form>


<span slot="footer" class="dialog-footer">
    <el-button @click="testSel.ok()" type="primary" size="mini">确定</el-button>
    <el-button @click="testSel.visible=false" size="mini">关闭</el-button>
</span>
</el-dialog>


//测试选择
testSel: testDialog({
    title: '同步测试',
    ok() {
        var that = this;
        Vue.http.post("priceTemplate/syncTest.do", { testCode: this.detail.testCode, dept: this.templateList.searchData.dept }, { emulateJSON: true }).then(function (response) {
            if (response.data.code == 1) {
                alert("同步成功")
                that.visible = false;
            } else {
                alert(response.data.message)
            }
        })
    }
}),


*/
// 

function testDialog(conf) {
    if (conf == null) {
        conf = {}
    }
    var obj = {
        title: '测试项目',
        visible: false,
        detail: {
            testCode: null,
        },
        open(testCode) {

            obj.detail.testCode = null;
            obj.visible = true;
        },
        ok() {
            console.info(obj.detail.testCode)
        }
    }
    return Object.assign(obj, conf);
}
